import java.util.*;

public class Practice5 {
    public static long gcd(long a,long b){
        return b == 0 ? a : gcd(b,a % b);
    }
    //https://www.nowcoder.com/practice/fe6c73cb899c4fe1bdd773f8d3b42c3d?tpId=122&tqId=33649&ru=/exam/oj
    //考察最大公约数加模拟
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextInt()){
            int n = sc.nextInt();
            int a = sc.nextInt();
            for(int i = 0;i < n;i++){
                int b = sc.nextInt();
                if(a >= b){
                    a += b;
                }else{
                    a += gcd(a,b);
                }

            }
            System.out.println(a);

        }

    }
}